package com.ibeeking.found.cop.b.rest.controller.v1;

import com.ibeeking.found.cop.b.rest.service.IFriendsLifeCyclePhaseService;
import com.ibeeking.found.cop.b.rest.service.IFriendsLifeCycleService;
import com.ibeeking.found.cop.service.common.param.FriendsLifeCycleParam;

import com.ibeeking.found.cop.service.common.query.FriendsLifeCyclePhaseQuery;
import com.ibeeking.found.cop.service.common.query.FriendsLifeCycleQuery;
import com.ibeeking.found.cop.service.common.vo.FriendsLifeCyclePhaseVO;
import com.ibeeking.found.cop.service.common.vo.FriendsLifeCycleVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName FriendsLifeCycleController
 * @Description 客户跟进管理
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/friendsLifeCycle/v1")
public class FriendsLifeCycleController {

    @Resource
    private IFriendsLifeCycleService friendsLifeCycleServiceImpl;

    @Resource
    private IFriendsLifeCyclePhaseService friendsLifeCyclePhaseServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询跟进流程设置列表")
    @PostMapping(value = "/list")
    public List<FriendsLifeCycleVO> list(@RequestBody FriendsLifeCycleQuery query) {
        return friendsLifeCycleServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加跟进流程")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) FriendsLifeCycleParam param) {
        return friendsLifeCycleServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改跟进流程")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) FriendsLifeCycleParam param) {
        return friendsLifeCycleServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/changeStatus/{id}/{status}")
    public Boolean changeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return friendsLifeCycleServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看跟进流程详情")
    @GetMapping(value = "/view/{id}")
    public FriendsLifeCycleVO view(@PathVariable("id") Long id) {
        return friendsLifeCycleServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除跟进流程")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return friendsLifeCycleServiceImpl.del(id);
    }


    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询跟进流程阶段列表")
    @PostMapping(value = "/phaseList")
    public List<FriendsLifeCyclePhaseVO> phaseList(@RequestBody FriendsLifeCyclePhaseQuery query) {
        return friendsLifeCyclePhaseServiceImpl.list(query);
    }
}
